//
//  PlayResultLayer.cpp
//  NewMath
//
//  Created by Ngô Hoàng Nam on 1/3/15.
//
//

#include "PlayResultLayer.h"
#include "../PlayManager.h"
//#include "../../../BaseObject/BaseGhostObj.h"
//#include "../Object/ResultGhostObj.h"
#include "../../../Objects/Ghost/Play/GhostResult.h"
#include "../../Level/LevelManager.h"

PlayResultLayer::PlayResultLayer(Size screenSize)
{
    m_screenSize = screenSize;
    //this->setPosition(m_screenSize.width/2,m_screenSize.height/2);
    //this->setAnchorPoint(Vec2(0.5f,0.5f));
    this->setAnchorPoint(Vec2(0,1.0f));
   
    
}
void PlayResultLayer::initalize(std::string equation, EGameStatus m_EGameStatus)
{
    GhostResult* ghost  = new GhostResult();
	this->addChild(ghost);

    Vec2 pos(m_screenSize.width/2,m_screenSize.height/3);
    float expectHeight = m_screenSize.height/3;
    float scale = expectHeight/kGhostSpriteHeight;
    if(m_EGameStatus == EGameStatus::kGhostStatus_Correct)
    {
        ghost->initalize(EGhostColor::kGhostColor_Random, EGhostFaceState::kGhostFaceState_Full, EGhostHandState::kGhostHandState_Happy, equation, pos, scale, m_EGameStatus == EGameStatus::kGhostStatus_Correct? true: false);
        switch (LevelManager::s_mode) 
		{
            case kMode_Easy:
                ghost->changeGhostState(EGhostStatus::kGhostStatus_Win_Easy);
                break;
            case kMode_Normal:
                ghost->changeGhostState(EGhostStatus::kGhostStatus_Win_Normal);
                break;
            case kMode_Hard:
                ghost->changeGhostState(EGhostStatus::kGhostStatus_Win_Hard);
                break;
            default:
                break;
        }
		ghost->m_status = ghost->m_ghostStatus;
    }
    else
    {
        ghost->initalize(EGhostColor::kGhostColor_Random, EGhostFaceState::kGhostFaceState_Full, EGhostHandState::kGhostHandState_Angry, equation, pos, scale, false);
        switch (LevelManager::s_mode) {
            case kMode_Easy:
                ghost->changeGhostState(EGhostStatus::kGhostStatus_Lose_Easy);
                break;
            case kMode_Normal:
                ghost->changeGhostState(EGhostStatus::kGhostStatus_Lose_Normal);
                break;
            case kMode_Hard:
                ghost->changeGhostState(EGhostStatus::kGhostStatus_Lose_Hard);
                break;
            default:
                break;
        }    }
        //BaseGhostObj::addToLayer(this, ghost);
    
    ghost->runDisplayAction();
}